package com.dingreading.cloud.subject.service.impl;

import com.dingreading.cloud.subject.dto.CourseTrainDto;
import com.dingreading.cloud.subject.entity.CourseTrain;
import com.dingreading.cloud.subject.entity.table.CourseTrainTableDef;
import com.dingreading.cloud.subject.mapper.CourseTrainMapper;
import com.dingreading.cloud.subject.service.CourseTrainService;
import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.core.relation.RelationManager;
import org.springframework.stereotype.Service;

/**
 * 叮叮线下培训课程表 服务层实现。
 *
 * @author EDY
 * @since 2025-11-18
 */
@Service
public class CourseTrainServiceImpl extends BaseServiceImpl<CourseTrainMapper, CourseTrain, CourseTrainTableDef> implements CourseTrainService {

    @Override
    protected CourseTrainTableDef getTable() {
        return CourseTrainTableDef.courseTrain;
    }

    @Override
    public CourseTrainDto getByUid(String uid) {
        QueryWrapper wrapper = QueryWrapper.create()
                .where(table.uid.eq(uid));
        return getMapper().selectOneWithRelationsByQueryAs(wrapper, CourseTrainDto.class);
    }

    @Override
    public CourseTrainDto getByUidNotFile(String uid) {
        QueryWrapper wrapper = QueryWrapper.create()
                .where(table.uid.eq(uid));
        RelationManager.addIgnoreRelations("fileList");
        return getMapper().selectOneWithRelationsByQueryAs(wrapper, CourseTrainDto.class);
    }
}
